package com.gupao.javavip.dubbo.rpc.serialize.messagepack;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.serialize.ObjectInput;
import org.apache.dubbo.common.serialize.ObjectOutput;
import org.apache.dubbo.common.serialize.Serialization;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class MessagepackSerialization implements Serialization {
    private static final byte ID = 11;
    //
    private static final String CONTENT_TYPE = "x-application/messagepack";

    @Override
    public byte getContentTypeId() {
        return ID;
    }

    @Override
    public String getContentType() {
        return CONTENT_TYPE;
    }

    @Override
    public ObjectOutput serialize(URL url, OutputStream output) throws IOException {
        return new MessagepackObjectOutput(output);
    }

    @Override
    public ObjectInput deserialize(URL url, InputStream input) throws IOException {
        return new MessagepackObjectInput(input);
    }
}
